package com.ruijixiang.leetcode.weekly.leetcode2024.leetcode20240901;

public class leetcode3277 {
    // 区间dp套区间dp
    public int[] maximumSubarrayXor(int[] nums,int[][] queries){
        int n=nums.length;
        int[][] f=new int[n][n];
        int[][] mx=new int[n][n];
        for(int i=n-1;i>=0;i--){
            f[i][i]=nums[i];
            mx[i][i]=nums[i];
            for(int j=i+1;j<n;j++){
                f[i][j]=f[i][j-1]^f[i+1][j];
                mx[i][j]=Math.max(f[i][j],Math.max(mx[i+1][j],mx[i][j-1]));
            }
        }

        int[] ans=new int[queries.length];
        for(int i=0;i<queries.length;i++){
            ans[i]=mx[queries[i][0]][queries[i][1]];
        }
        return ans;
    }
}
